// 修改手机号
import React, { Component } from 'react';
import {
    AppRegistry,
    View,
    Text,
    Image,
    StyleSheet,
    TextInput,
    TouchableOpacity,
} from 'react-native';

import { posedit_Style as styles1 } from '../../../../../styles';
import { suggestionStyle as styles } from '../../../../../styles';
import Icon from 'react-native-vector-icons/Ionicons';
import Autoinput from '../../../../util/inputUtil';

import { fetchRequest } from '../../../../util/fetch';
import { myAlert } from '../../../../util/compatible';

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;          //获取屏幕宽度
var height = Dimensions.get('window').height;

export default class Suggestion extends Component {
    constructor(props) {
        super(props);
        this.state = { idea: null };
    }

    _sendIdea(idea) {
        fetchRequest('XzRegister/sendIdea.go', 'POST', { idea: idea }).then(ret => {
            if (ret.msg === '已发送') {
                this.props.navigation.goBack()
            } else {
                myAlert('发送失败')
            }
        })
    }

    render() {
        return (
            <View style={styles.sugall}>
                <View style={[styles1.rtopin, {
                    width: width * 1,
                    elevation: 5,
                    shadowColor: 'black',
                    shadowOpacity: 1,
                    shadowRadius: 5
                }]}>

                    <TouchableOpacity activeOpacity={1} style={styles1.rtopicon1} onPress={() => { this.props.navigation.goBack() }}>
                        <Icon
                            name={'ios-arrow-back'}
                            size={25}
                            color={'#ffffff'} />
                    </TouchableOpacity>
                    <Text style={styles1.rtoptext}>意见反馈</Text>

                    <TouchableOpacity style={styles1.rtoptextout}
                        activeOpacity={1}
                        onPress={() => {
                            this._sendIdea(this.state.idea)
                        }}
                    >
                        <Text style={styles1.rtoptext2}>保存</Text>
                    </TouchableOpacity>

                </View >

                <View style={styles.sugcontent}>
                    <Autoinput
                        function={this.idea.bind(this)}
                        text={null}
                    />
                </View>

            </View>
        )
    }

    idea(a) {
        this.setState({ idea: a });
    }
}